<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>String对象</title>
</head>
<body>
<h1>课间思考：地址由那几部分构成??</h1>
<h1>协议头://host地址[ip/域名]:端口号/上下文?参数名1=参数值1&参数名2=参数值2#锚地址</h1>
<script>
    /**
     * sql字符过滤器
     * */
    function filterSqlStr(str) {
        var sqlList = ["-",",","*","#"];
        for (var sql in sqlList) {
            if(str.indexOf(sqlList[sql]) != -1){
                return false;
            }
        }
        return true;
    }

    /**
     * 获取地址参数
     * */
    // console.log("123456?5767987".split(""));
    // console.log("123456?5767987".substring(0,6));

    // function getUrlData(){
    //     var data = {};
    //     var url = location.href;    //获取当前页面的地址
    //     var dataList = url.split("?")[1].split("#")[0].split("&");
    //     for (var tempData in dataList) {
    //         console.log("参数名："+dataList[tempData].split("=")[0]);
    //         console.log("参数值："+dataList[tempData].split("=")[1]);
    //         data[dataList[tempData].split("=")[0]] = dataList[tempData].split("=")[1];
    //     }
    //     return data;
    // }
    function getUrlData(){
        var data = {};
        var dataList = location.href.split("?")[1].split("#")[0].split("&");
        for (var tempData in dataList) {
            data[dataList[tempData].split("=")[0]] = dataList[tempData].split("=")[1];
        }
        return data;
    }
    console.log(getUrlData());
</script>
</body>
</html>